import Taro from '@tarojs/taro'

/**
 * keep user login status
 * @param {*} key 
 * @param {*} val 
 */
export function setCache(key, val){
  let params = val
  if(typeof val === 'object'){
    params = JSON.stringify(val)
  }
  Taro.setStorageSync(key, params)
}

/**
 * read cache info
 * @param {*} key 
 */
export function getCache(key){
  let result = Taro.getStorageSync(key)
  if(result){
    result = JSON.parse(result)
  }else{
    return null
  }
  return result
}